#ifndef _FUN_TREES_H_
#define _FUN_TREES_H_

#include "rbtree.h"
#include "avllib.h"
#include "broadcast.h"
#include <stdint.h>
#define __weak __attribute__((weak))


/* 二叉平衡树 相关结构体及函数*/
typedef struct 
{
    struct avl_node avl_node;   //二叉平衡树节点
    void *key;                  //树上的节点值 默认key为int*，若key类型为其他类型
                                //请自行写对应的 fun_avl_compare
    void *user_data;            //用户数据
    //魔改数据
    struct broadcast_remote_info r_info;
}fun_avltree_unit;

int __weak fun_avl_compare(AVL_NODE *node, void *key);
int avltree_insert(AVL_TREE *root, fun_avltree_unit *unit);
fun_avltree_unit* avltree_delete(AVL_TREE *root, void *key);
fun_avltree_unit* avltree_search(AVL_TREE *root,void *key);
int avltree_destory(AVL_TREE *root);
int __weak avltree_destory_callback(AVL_NODE *pNode);
void __weak avltree_print(AVL_TREE root);

#endif
